import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';

import { Row, Col, Card, Button, message, Form, Input, Modal, InputNumber, Tree } from 'antd';

const TreeNode = Tree.TreeNode;


export default class CompanyTree extends React.Component {
  state = {
      loading: false,
      treeData: [],
  }
  onSelect = (selectedKeys, info) => {
      this.props.onSelectCompany(selectedKeys, info);
  }
  renderTreeNodes = (data) => {
      return data.map((item) => {
          if (item.children) {
              return (
                  <TreeNode title={item.title} key={item.key} dataRef={item}>
                      {this.renderTreeNodes(item.children)}
                  </TreeNode>
              );
          }
          return <TreeNode {...item} dataRef={item} />;
      });
  }
  render() {
      const { dispatch, data } = this.props;

      return (
          <Tree
              showLine
              autoExpandParent={true}
              onSelect={this.onSelect}
          >
              {this.renderTreeNodes(data)}
          </Tree>
      );
  }
}
